//
//  CZFooterView.swift
//  weibo24
//
//  Created by 李文峰 on 16/3/6.
//  Copyright © 2016年 fengten. All rights reserved.
//

import UIKit
import SnapKit
class CZFooterView: UIView {

    var statueseViewModel: CZStatusViewModel?{
        
        didSet{
            
            //转载数
            retweetButton.setTitle(statueseViewModel?.retweetString, forState: UIControlState.Normal)
        }
    }
    
    //三部曲
    
    //构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
        
//
   

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //添加和约束
    private func setupUI(){
        self.backgroundColor = UIColor.blueColor()
        
        addSubview(retweetButton)
        addSubview(commentsButton)
        addSubview(niceButton)
        
        let leftLine = getLine()
        let righutLine = getLine()
        addSubview(leftLine)
        addSubview(righutLine)
        
        //约束
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(commentsButton.snp_width)
        }
        niceButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.right.equalTo(self.snp_right)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(commentsButton.snp_width)
        }
        commentsButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.left.equalTo(retweetButton.snp_right)
            make.right.equalTo(niceButton.snp_left)
        }
        
        leftLine.snp_makeConstraints { (make) -> Void in
            make.centerX.equalTo(retweetButton.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            
        }
        righutLine.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(self.snp_centerY)
            make.centerX.equalTo(commentsButton.snp_right)
        }
        
        
    }
    //懒加载
    
    ///转发
    private lazy var retweetButton:UIButton = {
        
        let bt = UIButton(type: UIButtonType.Custom)
        
        bt.setTitle("转发", forState: UIControlState.Normal)
        bt.setImage(UIImage(named: "timeline_icon_retweet"), forState: UIControlState.Normal)
        bt.setTitleColor(UIColor(white: 0.95, alpha: 1.0), forState: UIControlState.Normal)
        
        
        return bt
        
        }()
    ///评论
    private lazy var commentsButton:UIButton = {
        let bt = UIButton(type: UIButtonType.Custom)
        
        bt.setTitle("评论", forState: UIControlState.Normal)
        bt.setTitleColor(UIColor(white: 0.95, alpha: 1.0), forState: UIControlState.Normal)
        bt.setImage(UIImage(named: "timeline_icon_comment"), forState: UIControlState.Normal)
        
        return bt
        
        }()
    ///赞
    private lazy var niceButton:UIButton = {
        
        let bt = UIButton(type: UIButtonType.Custom)
        
        bt.setTitle("赞", forState: UIControlState.Normal)
        bt.setTitleColor(UIColor(white: 0.95, alpha: 1.0), forState: UIControlState.Normal)
        bt.setImage(UIImage(named: "timeline_icon_like"), forState: UIControlState.Normal)
        
        return bt
        
        }()
    //创建一个方法,来返回一个UIImageView--线
    private func getLine() -> UIImageView{
        
        let imageView = UIImageView()
        
        imageView.image = UIImage(named: "timeline_card_bottom_line_highlighted")
        
        return imageView
    }
    
    
}
